/*----------------------
  PlayMidiLib.H header file

  http://www.tunesmithy.co.uk/playmidilib/index.htm

  E-mail support@tunesmithy.co.uk

  (c) Robert Walker 2002
----------------------*/

// Scroll down a page or so to see the list of routines :-)

// To add Quicktime to the list of devices to select from
// include QTMusicLib.dll in the smae folder as the executable.

// Be sure to call StopQT() before exit if you use Quicktime
// - it's not done every time you call StopMidiOut because it takes
// a while to start / stop QuickTime.
// - just call the routine whether you have used QT or not

#define compile_PM_as_DLL 

#ifdef compile_PM_as_DLL
#ifndef PM_DLL_EXPORT
#ifdef __cplusplus
#define PM_DLL_EXPORT extern "C" __declspec (dllexport)
#else
#define PM_DLL_EXPORT __declspec (dllexport)
#endif
#endif

#ifndef PM_DLL_CALLBACK
#define PM_DLL_CALLBACK    __stdcall
#endif

#else
#ifndef PM_DLL_EXPORT
#define PM_DLL_EXPORT
#endif
#ifndef PM_DLL_CALLBACK
#define PM_DLL_CALLBACK
#endif
#endif

#define PM_ADD_TO_WINDOWS_PROJECT 

#ifdef PM_ADD_TO_WINDOWS_PROJECT
#include <windows.h>
#endif

#define MAX_MIDI_VELOCITY 127
#define MAX_MIDI_NOTES 128
#define TOP_MIDI_NOTE 127
#define MAX_MIDI_VOICES 128
#define NON_MELODIC_PERCUSSION_CHANNEL 9
#define FIRST_GM_NON_MELOD_PERC 0
#define LAST_GM_NON_MELOD_PERC 127

#define MIDI_OUT_ERROR 0
#define MIDI_OUT_OK 1
#define MIDI_OUT_ALREADY_OPEN 2 // for OpenMidiOut(..) and StartMidiOut(..)

#define SZ_QT_INSTALL_INSTRUCTIONS \
  "How to install Quicktime for Midi apps:\n\n"\
   "Visit http://www.apple.com/quicktime/download/\n"\
   "Choose Custom Instll.\n\n"\
   "Then choose to install Quicktime Music, and Quicktime for Java.\n\n"\
   "If it doesn't let you install Quicktime for Java, then it probably\n\n"\
   "means you don't yet have Java 2 runtime Environment installed\n\n"\
   "You can get it from\n\n"\
   "http://java.sun.com/j2se/1.3/jre/download-windows.html\n"

PM_DLL_EXPORT int PM_DLL_CALLBACK nNumOutDevices (void);
PM_DLL_EXPORT char * PM_DLL_CALLBACK szNameForDevice (int iDev, char *szDeviceName, int iMAX_Name);

PM_DLL_EXPORT int PM_DLL_CALLBACK StartMidiOutForiDev(int iDev);
PM_DLL_EXPORT int PM_DLL_CALLBACK StartMidiOut (void);
PM_DLL_EXPORT void PM_DLL_CALLBACK StopMidiOut (void);
PM_DLL_EXPORT int PM_DLL_CALLBACK OpenMidiOut (int iDevice);
PM_DLL_EXPORT int PM_DLL_CALLBACK CloseMidiOut (void);
PM_DLL_EXPORT int PM_DLL_CALLBACK nChannelsAvailable (void);

PM_DLL_EXPORT double PM_DLL_CALLBACK dSecsSinceStartMidiOut (void);
PM_DLL_EXPORT void PM_DLL_CALLBACK SleepSeconds (double dSecs);

PM_DLL_EXPORT void PM_DLL_CALLBACK Set1o1 (double d1o1Freq);
PM_DLL_EXPORT void PM_DLL_CALLBACK SetMidiScale (char *sz);
PM_DLL_EXPORT void PM_DLL_CALLBACK	SetMidiVoice (int iVoice);
#define SetVoicePatches SetMidiVoice

PM_DLL_EXPORT void PM_DLL_CALLBACK TestPitchBendRange (void);
PM_DLL_EXPORT void PM_DLL_CALLBACK DoBendForScaleDegree (int ipos_in_scale);
PM_DLL_EXPORT void PM_DLL_CALLBACK DoBendForScaleDegreeInLoop (int ipos_in_scale);

PM_DLL_EXPORT void PM_DLL_CALLBACK PlayNonMelodicPercussion (int iNote, int iVelocity);
PM_DLL_EXPORT void PM_DLL_CALLBACK StopNonMelodicPercussion (int iNote, int iVelocity);
PM_DLL_EXPORT void PM_DLL_CALLBACK PlayScaleDegree (int ipos_in_scale, int iVelocity);
PM_DLL_EXPORT void PM_DLL_CALLBACK StopScaleDegree (int ipos_in_scale, int iVelocity);
PM_DLL_EXPORT void PM_DLL_CALLBACK PrintNotesInPlay (void);
PM_DLL_EXPORT void StopAllNotesPlayed (int iVelocity);

PM_DLL_EXPORT void PM_DLL_CALLBACK SetMidiScale (char *sz);
PM_DLL_EXPORT char * PM_DLL_CALLBACK GetszMostRecentScale (void);
PM_DLL_EXPORT int PM_DLL_CALLBACK GetnScaleNotes (void);
// #define nScaleNotes GetnScaleNotes // uncomment for compatability with old version of this header
PM_DLL_EXPORT void PM_DLL_CALLBACK	GetScaleFromText (double *dScaleIs, int *piNotesInScale, char *szBuffer, int iMAX_SCALE);

PM_DLL_EXPORT char * PM_DLL_CALLBACK GetMidiVoiceName (int iVoice, char *szVoiceFound, int iMax_szVoiceFound);
PM_DLL_EXPORT int PM_DLL_CALLBACK FindMidiVoice (char *szWords, char *szVoiceFound, int iMax_szVoiceFound);
PM_DLL_EXPORT void PM_DLL_CALLBACK PrintVoices (void);

PM_DLL_EXPORT int PM_DLL_CALLBACK CheckForQTLibrary (void);
PM_DLL_EXPORT int PM_DLL_CALLBACK StartQT (void);
PM_DLL_EXPORT void PM_DLL_CALLBACK StopQT (void);

#ifdef PM_ADD_TO_WINDOWS_PROJECT
PM_DLL_EXPORT int PM_DLL_CALLBACK FillComboWithMidiOutDevices(HWND hwndCombo);
PM_DLL_EXPORT int PM_DLL_CALLBACK FillListWithMidiOutDevices(HWND hwndList);
PM_DLL_EXPORT int PM_DLL_CALLBACK GetListSelMidiOutDevice(HWND hwndCombo,WPARAM wParam);
PM_DLL_EXPORT int PM_DLL_CALLBACK GetComboSelMidiOutDevice(HWND hwndCombo,WPARAM wParam);
PM_DLL_EXPORT int PM_DLL_CALLBACK SetListSelMidiOutDevice(HWND hwndList,int iDev);
PM_DLL_EXPORT int PM_DLL_CALLBACK SetComboSelMidiOutDevice(HWND hwndCombo,int iDev);

PM_DLL_EXPORT int PM_DLL_CALLBACK FillComboWithMidiVoices(HWND hwndCombo);
PM_DLL_EXPORT int PM_DLL_CALLBACK FillListWithMidiVoices(HWND hwndList);
PM_DLL_EXPORT int PM_DLL_CALLBACK GetListSelMidiVoice(HWND hwndList,WPARAM wParam);
PM_DLL_EXPORT int PM_DLL_CALLBACK GetComboSelMidiVoice(HWND hwndCombo,WPARAM wParam);
PM_DLL_EXPORT int PM_DLL_CALLBACK SetListSelMidiVoice(HWND hwndList,int iDev);
PM_DLL_EXPORT int PM_DLL_CALLBACK SetComboSelMidiVoice(HWND hwndCombo,int iDev);
#endif
